<?php
namespace Admin\Controller;
use Common\Controller\CommonController;
class LogController extends CommonController{
    public function index(){
        $this->display();
    }
    //登陆日志
    public function LoginLog(){
        $from_time = I('from_time','');
        $to_time = I('to_time','');
          
        if($from_time){
            $from_time_s = strtotime($from_time);
            $where['addtime']= array('EGT',$from_time_s);
            $shArray['from_time'] = $from_time;
        }
        
        if($to_time){
            $to_time_s = strtotime($to_time)+86400;
            $where['addtime']= array('ELT',$to_time_s);
            $shArray['to_time'] = $to_time; 
        }       
        
        if($from_time && $to_time){
            $where['login_time']=array(array('EGT',$from_time_s),array('ELT',$to_time_s),'and');
        }   
        // if(I('type') != ''){
        // $where['a_type'] = I('type');
        // $shArray['a_type'] = I('type'); 
        // }


         $page= I('p',1);
         $pageCount = 10;
         $list = M('login_log')->where($where)->order('login_time desc')->page($page.','.$pageCount)->limit($Page->firstRow.','.$Page->listRows)->select();
         //$typeList = M('Archive_type')->select();
              
         foreach($list as  $key => $item ){
            // $list[$key]['a_typename']  = M('Archive_type')->where('at_typeid="'.$item['a_type'].'"')->getField('at_type_name');
         }
        
         $count = M('login_log')->where($where)->limit($Page->firstRow.','.$Page->listRows)->count();// 查询满足要求的总记录数
         // $this->assign('count',$count);// 赋值分页输出    
         $Page = new \Think\Page($count,$pageCount);// 实例化分页类 传入总记录数和每页显示的记录数
        
         $show = $Page->show();// 分页显示输出
         // $this->assign('typelist', $typeList);
         // $this->assign('shArray',$shArray);// 搜索参数输出
         
         $this->assign('page',$show);// 赋值分页输出    
         $this->assign('info', $list);
         $this->display();
    }
    //行为日志
    public function LogBehavior(){
        $from_time = I('from_time','');
        $to_time = I('to_time','');
          
        if($from_time){
            $from_time_s = strtotime($from_time);
            $where['addtime']= array('EGT',$from_time_s);
            $shArray['from_time'] = $from_time;
        }
        
        if($to_time){
            $to_time_s = strtotime($to_time)+86400;
            $where['addtime']= array('ELT',$to_time_s);
            $shArray['to_time'] = $to_time; 
        }       
        
        if($from_time && $to_time){
            $where['time']=array(array('EGT',$from_time_s),array('ELT',$to_time_s),'and');
        }   
        // if(I('type') != ''){
        // $where['a_type'] = I('type');
        // $shArray['a_type'] = I('type'); 
        // }
         $page= I('p',1);
         $pageCount = 10;
         $list = M('behavior_log')->where($where)->order('time desc')->page($page.','.$pageCount)->limit($Page->firstRow.','.$Page->listRows)->select();
         //$typeList = M('Archive_type')->select();
              
         foreach($list as  $key => $item ){
            // $list[$key]['a_typename']  = M('Archive_type')->where('at_typeid="'.$item['a_type'].'"')->getField('at_type_name');
         }
        
         $count = M('behavior_log')->where($where)->count();// 查询满足要求的总记录数
         // $this->assign('count',$count);// 赋值分页输出    
         $Page = new \Think\Page($count,$pageCount);// 实例化分页类 传入总记录数和每页显示的记录数
         $show = $Page->show();// 分页显示输出
         // $this->assign('typelist', $typeList);
         // $this->assign('shArray',$shArray);// 搜索参数输出
         $this->assign('page',$show);// 赋值分页输出    
         $this->assign('info', $list);
         $this->display();





        // $mod=M("log_behavior");
        // $info=$mod->select();
        // $this->assign("info",$info);
        // $this->display();
    }

    
}